function db(sql, callback) {
  var mysql = require('mysql');
  var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',  //修改名字
    password: '', //修改密码
    database: 'qiaozhi' //修改数据库
  });

  connection.connect();

  connection.query(sql, callback)

  connection.end();
}

//封装之后,函数在其他文件中使用,所以要导出
module.exports = db;


//调用
// db('select *from  student', (err, result) => {
//   if (err) throw err;
//   console.log(result);
// })